/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fuzzy.tools;

import fuzzy.hibernate.Uzytkownicy;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author michal
 */
public class Tools {
    
    public static int getClientId(String clientId) {
        if (clientId != null) {
            return Integer.parseInt(clientId);
        }
        
        return 0;
    }
    
    public static Uzytkownicy getUser(HttpServletRequest request) {
        Uzytkownicy user = (Uzytkownicy) request.getSession().getAttribute("user");
        
        if (user == null) {
            user = new Uzytkownicy();
            user.setRola("anonim");
        }
        
        return user;
    }
}
